<template>
	<el-dialog v-model="visible" :title="!dataForm.id ? '新增' : '修改'" :close-on-click-modal="false" draggable width="70%">
		<el-form ref="dataFormRef" :model="dataForm" :rules="dataRules" style="height:250px;" label-width="120px" @keyup.enter="submitHandle()">
			<div class="divlineprofirst">
				<el-form-item prop="remark" label="跟踪内容">
					<el-input v-model="dataForm.remark" rows="12" type="textarea" class="textinput"  placeholder="请输入客户跟踪内容"></el-input>
				</el-form-item>
			</div>
		</el-form>
		<template #footer>
			<div class="divbtn">
				<el-button @click="visible = false">取消</el-button>
				<el-button  v-auth="'sys:customer:save'" type="primary" @click="submitHandle()">确定</el-button>
			</div>
		</template>
	</el-dialog>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue'
import { ElMessage } from 'element-plus/es'
import {useCustomerInfoSubmitApi,useCustomerInfoApi} from '@/api/sys/customerinfo'
import {useCustomerSubmitApi,useCustomerApi} from '@/api/sys/customer'
const emit = defineEmits(['refreshDataList'])

const visible = ref(false)
const dataFormRef = ref()
const dataForm = reactive({
	id:'',
	customerId:'',
	userName:localStorage.getItem('realName'),
	userId:localStorage.getItem('userCd'),
	remark:''
})
const init = (obj:any) => {
	visible.value = true
	dataForm.customerId = obj.uid;
	// 重置表单数据
	if (dataFormRef.value) {
		dataFormRef.value.resetFields()
	}
}
const dataRules = ref({
	remark: [{ required: true, message: '必填项不能为空', trigger: 'blur' }]
})
// 表单提交
const submitHandle = () => {
	dataFormRef.value.validate((valid: boolean) => {
		if (!valid) {
			return false
		}
		useCustomerInfoSubmitApi(dataForm).then((res:any) => {
			
			ElMessage.success({
				message: '操作成功',
				duration: 500,
				onClose: () => {
					visible.value = false
					emit('refreshDataList')
				}
			})
		})
	})
}

defineExpose({
	init
})
</script>
<style lang="scss" scoped>
.divlineprofirst{
	width: 96%;
	height: 180px;
	float: left;
}
.divline {
	width: 96%;
	height: 30px;
	float: left;
	margin-top: 20px;
}
.divlinepro{
	width: 99%;
	height: 30px;
	float: left;
	margin-top: 20px;
}
.divlineprofirst{
	width: 96%;
	height: 180px;
	float: left;
}
.textinput.el-textarea__inner{
	width: 90%;
	float: left;
	height: 500px;
}
.divfileline{
	width: 96%;
	float: left;
	margin-left: 40px;
	margin-top: 40px;
}
.divlineleft{
	width: 47%;
	float: left;
	height: 30px;
	padding-left: 10px;
}

.divlinecenter{
	width: 95.5%;
	float: left;
	height: 30px;
	padding-left: 10px;
}
.divbtn{
	text-align: center;
	margin-top: 20px;

}
.eduline{
	width: 96%;
	float: left;
	height: 50px;
	margin-top: 15px;
	border-bottom: 1px solid #BEBEBE;
	border-top: 1px solid #BEBEBE;
}
.divsplit{
	width: 96%;
	float: left;
	height: 1px;
	background-color:#409eff;
    margin-top: 5px;
}
.divsplit:last-child{
	width: 96%;
	float: left;
	height: 1px;
}
.eduitem{
	width: 20%;
	height: 30px;
	float: left;
    padding-top: 10px;
}
.inputVal.el-input__wrapper{
	width: 60%;
	float: left;
	height: 30px;
}
.inputVal.el-input{
	width: 60%;
	float: left;
	height: 30px;
}
.texttit{
	width: 30%;
	float: left;
	height: 30px;
	line-height: 2;
}
.eduitembtn{
	
	width: 19%;
	height: 30px;
	float: left;
    padding-top: 10px;
}
</style>
